package org.springService.test;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;


public class CallableDemo implements Callable<Integer> {

	@Override
	public Integer call() throws Exception {
		int i = 5;
		for( ; i<100 ; i++){
			System.out.println(Thread.currentThread().getName() + "call的循环变量i的值：" +i);
		}
		//call()方法可以有返回值
		return i;
	}

	
	public static void main(String[] args) {
		//创建Callable对象
		CallableDemo cd = new CallableDemo();
		//使用FutureTask来包装Callable对象
		FutureTask<Integer> task = new FutureTask<Integer>(cd);
	    //实质还是以Callable对象来创建并启动线程
	    new Thread(task).start();
 
	}

}

